#include "head.h"

/* Usage:  服务端*/

void do_cd(int net_fd, self_defined_pro_t *protect){


    char *username=strtok(protect->message,"=");
    username=strtok(NULL,"&");
    char *path=strtok(NULL,"=");
    path=strtok(NULL,"&");
    char *cd_dir=strtok(NULL,"=");
    cd_dir=strtok(NULL,"&");


    char all_path[200] = {0};
    strcat(all_path, username);
    strcat(all_path, path);
    if(strlen(path) != 1){
        strcat(all_path, "/");
    }
    strcat(all_path, cd_dir);

    if(access(all_path, F_OK) == 0){
        protect->cmd = 0;
        protect->para_num = 2;
        send(net_fd, protect, sizeof(self_defined_pro_t), MSG_NOSIGNAL);
    }else{
        protect->cmd =60;
        send(net_fd, protect, sizeof(self_defined_pro_t), MSG_NOSIGNAL);
        return;
    }

    return ;
}


